package com.qin.springbootdemo.service;

import com.qin.springbootdemo.dao.cartsDao;
import com.qin.springbootdemo.dao.favoriteDao;
import com.qin.springbootdemo.dao.goodsDao;
import com.qin.springbootdemo.entity.cartlistEntity;
import com.qin.springbootdemo.entity.commodities;
import com.qin.springbootdemo.entity.favoriteEntity;
import com.qin.springbootdemo.entity.swiper;
import org.apache.tomcat.jni.Address;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Leisure
 * create 2022 2022/6/18 10:27
 **/
@Service
public class webService {
    @Autowired
    private goodsDao goods;

    @Autowired
    private cartsDao carts;

    @Autowired
    private favoriteDao favorite;

    //查询所有商品
    public List<commodities> findGoodsAll(){
        return this.goods.findGoodsAll();
    }

    //查轮播图
    public List<swiper> findSwiper(){
        return this.goods.findSwiper();
    }

    //查商品的名称
    public List<commodities> findSpecificGoods(String key){
        return this.goods.findSpecificGoods(key);
    }

    //查到商品ID
    public commodities findGoodById(String id){
        return this.goods.findGoodById(id);
    }


//以下为购物车模块
    //查购物车
    public List<cartlistEntity> findCartAll(){
        return this.carts.findCartAll();
    }
    //加入购物车
    public cartlistEntity insertCart(cartlistEntity cart) {
        return this.carts.insertCart(cart);
    }
    //更新购物车
    public cartlistEntity updateCart(cartlistEntity cart) {
        // TODO Auto-generated method stub
        return this.carts.updateCart(cart);
    }
    //删除购物车
    public void delCart(String id) {
        this.carts.delCart(id);
    }

//以下为收藏模块
    //查收藏
    public List<favoriteEntity> findFavoriteAll(){
    return this.favorite.findFavoriteAll();
}
    //删除收藏
    public void delFavorite(String id) {
        this.favorite.delFavorite(id);
    }

    //插入收藏
    public Address insertFavorite(favoriteEntity favorite) {
        return this.favorite.insertFavorite(favorite);
    }
}
